import Vue from 'vue'
import App from './App.vue'
import router from './router'
// import store from './store'
import '../public/element'
import '../src/assets/style.css'
// 导入富文本编辑器

// 导入富文本编辑器对应的样式
// import 'quill/dist/quill.core.css' // import styles
// import 'quill/dist/quill.snow.css' // for snow theme
// import 'quill/dist/quill.bubble.css' // for bubble theme

import VueQuillEditor from 'vue-quill-editor'
Vue.use(VueQuillEditor)

Vue.config.productionTip = false

// 过滤器
Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)

  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

// 路由守卫 to将要跳转的路径 from从哪个路径过来
// next()放行 next('/login')强制跳转
router.beforeEach((to, from, next) => {
  // 如果是在login就放行
  if (to.path === '/login') {
    next()
  }
  // 取出token
  const token = window.sessionStorage.getItem('token')
  // 如果没有token就强制跳转到login
  if (!token) return next('/login')
  next()
})

new Vue({

  router,
  // store,
  render: h => h(App)
}).$mount('#app')
